#输出矩阵============================================================

import numpy as np

a = np.array([1,2,3,4])
print(a)

# ===================================================================

import  time

a = np.random.rand(1000000)
b = np.random.rand(1000000)

#向量化计算===========================================================

tic = time.time()
c = np.dot(a,b)
toc = time.time()

print("c = "+str(c))
print("Vectorized version:"+str(1000*(toc-tic))+"ms")

#非向量化（循环）计算=================================================
c = 0
tic = time.time()
for i in range(1000000):
    c += a[i]*b[i]
toc = time.time()
print("c = "+str(c))
print("For loop:"+str(1000*(toc-tic))+"ms")